#pragma once

template<class iterator, class Ref, class Ptr>
struct reverseiterator
{
	typedef reverseiterator<iterator,Ref,Ptr> self;
	iterator cur;

	reverseiterator(iterator it)
		:cur(it)
	{}

	self& operator ++ ()
	{
		--cur;
		return *this;
	}

	self& operator -- ()
	{
		++cur;
		return *this;
	}


	Ref operator*()
	{
		iterator tmp = cur;
		--tmp;
		return *tmp;
	}

	Ptr operator ->()
	{
		return &(operator*());
	}

	bool operator != (const self& s)
	{
		return cur != s.cur;
	}

	bool operator == (const self& s)
	{
		return cur == s.cur;
	}

};
